#include<bits/stdc++.h>
using namespace std;
int f[111111],a[111111],h[111111],ans;
int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i],f[i]=INT_MAX;
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
    {
        int t=upper_bound(f+1,f+n+1,-a[i])-f;
        if(t==n+1) continue;
        f[t]=-a[i];
        h[t]++;
        ans=max(ans,t);
    }
    cout<<ans<<endl;
    return 0;
}
